/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * UserManagmentPortlet.java
 *
 * Created on 31/03/2011, 08:23:48
 */
package wf.ui.layouts;

import bc.dsl.PageDSL;
import bc.swing.pfrm.Page;
import bc.swing.pfrm.PageLayout;

/**
 *
 * @author bennyl
 */
public class ManagmentPortletLayout extends javax.swing.JPanel implements PageLayout{
    public static final String CENTER_ROLE = "CENTER ROLE";

    /** Creates new form UserManagmentPortlet */
    public ManagmentPortletLayout() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        caption = new javax.swing.JLabel();
        centerPan = new javax.swing.JPanel();
        actionsPan = new javax.swing.JPanel();

        setBackground(new java.awt.Color(102, 102, 102));
        setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 2));
        setLayout(new java.awt.GridBagLayout());

        caption.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        caption.setForeground(new java.awt.Color(255, 255, 255));
        caption.setText("Connected Controllers");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        add(caption, gridBagConstraints);

        centerPan.setOpaque(false);
        centerPan.setLayout(new java.awt.BorderLayout());
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
        add(centerPan, gridBagConstraints);

        actionsPan.setOpaque(false);
        actionsPan.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        add(actionsPan, gridBagConstraints);
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel actionsPan;
    private javax.swing.JLabel caption;
    private javax.swing.JPanel centerPan;
    // End of variables declaration//GEN-END:variables

    @Override
    public void setPage(Page page) {
        caption.setText(page.getName());
        caption.setIcon(page.getIcon());
        
        PageDSL.fillByRole(page, centerPan, CENTER_ROLE);
        PageDSL.appendActions(page.getActions(), actionsPan);
        validate();
        repaint();
    }

    @Override
    public void onDispose() {
//        throw new UnsupportedOperationException("Not supported yet.");
    }

}
